﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Kaidou.Persister;
using Kaidou.Model;
using System.Collections.Generic;
using Kaidou.Util;
using Kaidou.Bll;

public partial class master_master_branch_conf : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        LoginModel loginModel = (LoginModel)Session["loginModel"];

        if (loginModel == null)
        {
            Response.Redirect("../login.aspx");
        }
        else if (!loginModel.isOperator())
        {
            Response.Redirect("../menu.aspx");
        }

        string area = Resources.Resource.area;
        string[] areaArray = area.Split(',');

        mst_union_branch M = (mst_union_branch)Session["mstunionbranch"];
        MST_UnionPersister dao2 = new MST_UnionPersister();
        MstUnion parent = dao2.getDetail(M.Id.unioncode);
        union_code.Text = M.Id.unioncode + " " + parent.OfficeName; ;
        branch_code.Text = StringUtil.getBranchCodeNumberFormat( M.Id.branchcode);
        office_address.Text = M.officeaddress;
        office_city.Text = M.officecity;
        office_email.Text = M.officeemail;
        office_fax.Text = M.officefax;
        office_kana.Text = M.officekana;
        office_name.Text = M.officename;
        office_pref_code.Text = areaArray[M.officeprefcode - 1];
        office_tel.Text = M.officetel;
        office_zip_no.Text = M.officezipno;
        tanto_kana.Text = M.tantokana;
        tanto_name.Text = M.tantoname;
        //user_clss.Text = int.Parse(M.UserClss) == StringUtil.USER_CLSS_KUMIAIIN ? Resources.Resource.user_clss_a : int.Parse(M.UserClss) == StringUtil.USER_CLSS_JIMUKYOKU ? Resources.Resource.user_clss_b : Resources.Resource.user_clss_c;
    }

    protected void login_confirm(object sender, EventArgs e)
    {
        MST_Union_BranchPersister dao = new MST_Union_BranchPersister();
        mst_union_branch M = (mst_union_branch)Session["mstunionbranch"];
        try
        {
            dao.insertMasterBranch(M);
        }
        catch(Exception ee)
        {
            LogManager.error("master_master_branch_conf - insertMasterBranch "+ee.Message);
        }

        Response.Redirect("master_branch.aspx");
    }
}
